package ebcs.scan.common.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

 
public class Properties {

	private static final String CONFIG = "conf";
	private static ResourceBundle CONFIG_RES = ResourceBundle.getBundle(CONFIG);
 	private static java.util.Properties comm_ps = null;
	private Properties() {
	}

	public static String getString(String key) {
		try {
			return CONFIG_RES.getString(key);
		} catch (MissingResourceException e) { }
		return "";
	}
	 
	public static int getInt(String key) {
		String value = getString(key);
		if (!ParamUtil.isEmpty(value)) {
			try {
				return Integer.parseInt(value);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return 0;
	}

	public static boolean getBoolean(String key) {
		log("find-key="+key+";value="+getString(key));
		return "true".equals(getString(key));
	}
////	
	public static String getIbsConfString(String key) {
		if (comm_ps == null) {
			try {
				comm_ps = new java.util.Properties();
				comm_ps.load(new FileInputStream(new File(Properties.getString("IBS_CONF"))));
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		System.out.println("...........222..IBSM_CONF:"+ Properties.getString("IBS_CONF")+ "initing successfully!!!");
		return comm_ps.getProperty(key);
	}

	public static void log( String lgmsg )
	{
		Thread currTh = Thread.currentThread();
		System.out.println( ""+currTh.getId()+"-"+currTh.getName()+":"+lgmsg );
	}
}